package com.hw.springcloud.service.impl;

import com.hw.springcloud.service.IMessageReceive;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @Classname: IMessageReceiveImpl
 * @Description: 描述
 * @Date: 2021/12/7
 * @Author: HuWei
 */
@Component
@EnableBinding(Sink.class)
public class IMessageReceiveImpl implements IMessageReceive {

    @Value("${server.port}")
    private String serverPort;

    @Override
    @StreamListener(Sink.INPUT)
    public void receiveMessage(Message<String> msg) {
        String payload = msg.getPayload();
        System.out.println("消费者8803接收到消息"+payload+"\t"+"端口号:"+serverPort);
    }
}
